﻿Imports System.Data
Partial Class Form_KYCResultBiz
    Inherits Web.UI.BasePage
    Dim ds As DataSet
    Dim uniqueID1 As String
    Dim BizType As String
    Dim PrefixTH As String
    Dim NameTh1 As String
    Dim NameEn1 As String
    Dim Nationality As String
    Dim Business1 As String
    Dim BizOther1 As String
    Dim Des1 As String
    Dim Business2 As String
    Dim BizOther2 As String
    Dim Des2 As String
    Dim Business3 As String
    Dim BizOther3 As String
    Dim Des3 As String
    Dim IncomeSource1 As String
    Dim IncomeSource2 As String
    Dim IncomeSource3 As String
    Dim Level As String
    Dim Reason As String
    Dim clsDataTable As New clsLINQToDataTable
    Dim convertDate As clsDateFormat

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache")
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("Expires", "0")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            ds = Session("ds")

            QueryString()

            If Not IsPostBack Then
                AutoInput()
                grdList.DataSource = ds.Tables("dsList")
                grdList.DataBind()
                checkList()

                Response.Write("<script>")
                Response.Write("window.print()")
                Response.Write("</script>")
            End If
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "clientScript", "alert('" + ex.Message.Replace("'", "") + "')", True)
        End Try
    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        Session("ds") = ds
    End Sub

#Region "Function"

    Private Sub QueryString()

        Try
            uniqueID1 = Request.QueryString("uniqueID").Trim
            BizType = Request.QueryString("BizType").Trim
            PrefixTH = Request.QueryString("PrefixTH").Trim
            NameTh1 = Request.QueryString("NameTh1").Trim
            NameEn1 = Request.QueryString("NameEn1").Trim
            Nationality = Request.QueryString("Nationality").Trim
            Business1 = Request.QueryString("Business1").Trim
            BizOther1 = Request.QueryString("BizOther1").Trim
            Des1 = Request.QueryString("Des1").Trim
            Business2 = Request.QueryString("Business2").Trim
            BizOther2 = Request.QueryString("BizOther2").Trim
            Des2 = Request.QueryString("Des2").Trim
            Business3 = Request.QueryString("Business3").Trim
            BizOther3 = Request.QueryString("BizOther3").Trim
            Des3 = Request.QueryString("Des3").Trim
            IncomeSource1 = Request.QueryString("IncomeSource1").Trim
            IncomeSource2 = Request.QueryString("IncomeSource2").Trim
            IncomeSource3 = Request.QueryString("IncomeSource3").Trim

            Level = Request.QueryString("RiskLevel").Trim
            Reason = Session("strReason")
        Catch ex As Exception
            WriteError(ex, "QueryString", "KYCResultBiz")
            Throw ex
        End Try

    End Sub

    Private Sub AutoInput()
        Try
            lblUniqueID.Text = uniqueID1
            lblTHName.Text = NameTh1
            lblENName.Text = NameEn1.ToUpper

            lblLevel.Text = Level
            If Not Reason Is Nothing Then
                If Not Reason = "undefined" Then
                    'lblReason.Text = Reason
                    lblReason.Text = Reason.Replace("-", "<br> - ")
                End If
            End If


            Dim convertDate As clsDateFormat = New clsDateFormat
            lblDate.Text = convertDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, Now.Date)
            convertDate = Nothing

            lblTime.Text = Now.ToShortTimeString

            Dim clsSessionMenuRight As clsSessionMenuRight = New clsSessionMenuRight
            clsSessionMenuRight = Session("clsMenuRight")
            lblUser.Text = clsSessionMenuRight.getEmpFirstName + "&nbsp;&nbsp;" + clsSessionMenuRight.getEmpLastName
            clsSessionMenuRight = Nothing
        Catch ex As Exception
            WriteError(ex, "AutoInput", "KYCResultBiz")
            Throw ex
        End Try
    End Sub

    Private Sub checkList()
        Try
            Dim check As Boolean = False
            If grdList.Rows.Count = 0 Then
                rdoSanction.SelectedIndex = 1
                lblMsg.Text = "ไม่พบรายชื่อใน List"
                ' lblMsg.Visible = True
                Exit Sub
            Else
                Dim chk As CheckBox
                For i As Integer = 0 To grdList.Rows.Count - 1
                    chk = CType(grdList.Rows(i).FindControl("chkList"), CheckBox)
                    If chk.Checked = True Then
                        check = True
                        Exit For
                    End If
                Next
            End If

            If check = True Then
                rdoSanction.SelectedIndex = 0
                lblMsg.Text = "พบรายชื่อใน List"
            Else
                rdoSanction.SelectedIndex = 1
                lblMsg.Text = "ไม่พบรายชื่อใน List"
                '   lblMsg.Visible = True
            End If
        Catch ex As Exception
            WriteError(ex, "checkList", "KYCResultBiz")
            Throw ex
        End Try

    End Sub

#End Region

    Protected Sub grdList_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdList.RowDataBound
        Try
            If (e.Row.RowType.ToString = "DataRow") Then
                Dim lblActiveDate As Label = CType(e.Row.FindControl("lblActiveDate"), Label)
                If Not (lblActiveDate.Text = "") Then
                    convertDate = New clsDateFormat
                    lblActiveDate.Text = convertDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, lblActiveDate.Text)
                    convertDate = Nothing
                End If
            End If
        Catch ex As Exception
            WriteError(ex, "grdList_RowDataBound", "KYCResult")
            Throw ex
        End Try
    End Sub
End Class
